public class Singleton {
    //懒汉模式
    private volatile static Singleton instance;
    private Object locker = new Object();
    public Singleton getInstance() {
        if(instance == null) {
            synchronized (locker) {
                if (instance == null)
                    instance = new Singleton();
            }
        }
        return instance;
    }

    private Singleton(){}
}
